//
//  ViewController.m
//  iOSDemo
//
//  Created by Steve on 2021/3/8.
//

#import "ViewController.h"
#import "LBHPerson.h"
#import "LBHStudent.h"
#import "UITextField+YYBBAdd.h"


@interface ViewController ()
@property (copy, nonatomic) dispatch_block_t myBlock;
@property (copy, nonatomic) NSString *blockString;

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    LBHPerson *person = [[LBHPerson alloc] init];
    person.eat(@"吃").sleep(@"睡大街");
    [person calculator:^NSInteger(NSInteger result) {
        result = result+10;
        result = result*10;
        return result;
    }];
    NSLog(@"%ld", person.result);

    NSLog(@"%ld",(long)[self compareVersion:@"3.2.0" withVersion2:@"3.1.10"]);
    [person makecalculator:^(AddCalculator *addcalculator) {
         addcalculator.add(10).add(30);
    }];
    NSLog(@"person : %ld", person.result);

//    UITextField *txtfield = [UITextField alloc]
//     黑魔法坑点二: 子类没有实现 - 父类实现
//    LBHStudent *s = [[LBHStudent alloc] init];
//    [s personInstanceMethod];
//
//    LBHPerson *p = [[LBHPerson alloc] init];
//    [p personInstanceMethod];
//
//
//    [self testWithBlock:^{
//        NSLog(@"%@",self);
//    }];
//
    
//    __weak typeof(self) weakSelf = self;
//
//    self.myBlock = ^() {
//
//            __strong __typeof(self) strongSelf = weakSelf;
//
//            [strongSelf test];
//     };
}


//- (void)testWithBlock:(dispatch_block_t)block {
//    block();
//}
//
//- (void)bossAngry
//{
//    NSLog(@"222");
//}


- (NSComparisonResult )compareVersion:(NSString *)oldVersion withVersion2:(NSString *)newVersion
{
    NSArray *v1Arr = [oldVersion componentsSeparatedByString:@"."];
    NSArray *v2Arr = [newVersion componentsSeparatedByString:@"."];
    NSInteger v1Count = v1Arr.count;
    NSInteger v2Count = v2Arr.count;
    NSInteger maxCount = MAX(v1Count, v2Count);
    for (NSInteger i = 0; i < maxCount; i++) {
        NSInteger v1 =  i <v1Count ? [v1Arr[i] integerValue] : 0;
        NSInteger v2 =  i <v2Count ? [v2Arr[i] integerValue] : 0;
        if (v2 > v1 ) {
            return NSOrderedDescending;
        }else if (v2 < v1){
            return NSOrderedAscending;
        }
    }
    return  NSOrderedSame;
 
}
    
 




@end
